import { defineStore } from 'pinia'

export const useSettingsStore = defineStore('settings', {
  state: () => ({
    darkMode: false,
    notifications: true
  }),
  actions: {
    setDarkMode(val: boolean) {
      this.darkMode = val
      localStorage.setItem('darkMode', val ? '1' : '0')
    },
    setNotifications(val: boolean) {
      this.notifications = val
    },
    loadSettings() {
      const dark = localStorage.getItem('darkMode')
      if (dark !== null) this.darkMode = dark === '1'
    }
  }
})